<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增奖励')" />
    <th:block th:include="include :: datetimepicker-css" />
    <th:block th:include="include :: bootstrap-fileinput-css"/>
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-reward-add">
            <div class="row">
                <div class="col-xs-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label is-required">申请人：</label>
                        <div class="col-sm-8">
                            <!--                        <select name="userId" class="form-control m-b" disabled>-->
                            <!--                            <option th:each="user : ${sysUsers}" th:text="${user.userName}" th:value="${user.userId}" th:selected="${user.flag}"></option>-->
                            <!--                        </select>-->
<!--                            <select name="userId" class="form-control m-b" >-->
<!--                                <option th:each="user : ${sysUsers}" th:text="${user.userName}" th:value="${user.userId}" th:selected="${user.flag}"></option>-->
<!--                            </select>-->
                            <div th:each="user : ${sysUsers}" th:if="${user.flag}">
                                <input  class="form-control" type="text" th:value="${user.userName}" readonly>
                                <input name="userId" class="form-control" type="hidden" th:value="${user.userId}">
                            </div>
                        </div>
                    </div>
                </div>

                <div class="col-xs-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">荣誉名称：</label>
                    <div class="col-sm-8">
                        <input name="rewardName" class="form-control" type="text" required>
                    </div>
                </div>
                </div>

                <div class="col-xs-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">颁发单位：</label>
                    <div class="col-sm-8">
                        <input name="rewardDanwei" class="form-control" type="text" required>
                    </div>
                </div>
                </div>

                <div class="col-xs-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">奖励类型：</label>
                    <div class="col-sm-8">
                        <input name="rewardLeixing" class="form-control" type="text" required>
                    </div>
                </div>
                </div>



                <div class="col-xs-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">颁发时间：</label>
                    <div class="col-sm-8">
                        <div class="input-group date">
                            <input name="rewardTime" class="form-control" placeholder="yyyy-MM-dd" type="text" required>
                            <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                        </div>
                    </div>
                </div>
                </div>

                <div class="col-xs-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">分类：</label>
                    <div class="col-sm-8">
                        <select name="rewardFenlei" class="form-control"  type="text" th:with="type=${@dict.getType('sys_reward_fenlei')}" required >
<!--                            <option value="省级教学成果奖">省级教学成果奖</option>-->
<!--                            <option value="省级科学技术奖">省级科学技术奖</option>-->
<!--                            <option value="省级一流精品课评比">省级一流精品课评比</option>-->
<!--                            <option value="市、厅局级自然科学类评奖">市、厅局级自然科学类评奖</option>-->
<!--                            <option value="市、厅局级社科类评奖">市、厅局级社科类评奖</option>-->
<!--                            <option value="校级教学成果奖">校级教学成果奖</option>-->
<!--                            <option value="应用型科研校级成果奖">应用型科研校级成果奖</option>-->
<!--                            <option value="校级精品课评比">校级精品课评比</option>-->
<!--                            <option value="指导学生参加国家科创大赛且获得名次">指导学生参加国家科创大赛且获得名次</option>-->
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                        </select>
                    </div>
                </div>
                </div>


<!--                <div class="col-sm-6">-->
<!--                    <label class="col-sm-4 control-label is-required">分类：</label>-->
<!--                    <div class="col-sm-8">-->
<!--                        <select name="fenlei" class="form-control" th:with="type=${@dict.getType('sys_zhuanli_fenlei')}" required>-->
<!--                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>-->
<!--                        </select>-->
<!--                    </div>-->
<!--                </div>-->
                    <div class="col-xs-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">排名：</label>
                    <div class="col-sm-8">
                        <select name="rewardPaiming"  class="form-control" type="text" th:with="type=${@dict.getType('sys_reward_paiming')}" required >
<!--                            <option value="一">一</option>-->
<!--                            <option value="二">二</option>-->
<!--                            <option value="三">三</option>-->
<!--                            <option value="四">四</option>-->
<!--                            <option value="五">五</option>-->
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                        </select>
                    </div>
                </div>
                    </div>

                <div class="col-xs-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required" for="rewardJibie">级别：</label>
                    <div class="col-sm-8">
                        <select id="rewardJibie" name="rewardJibie" class="form-control" required>
                            <option value="校级">校级</option>
                            <option value="省级">省级</option>
                        </select>
                    </div>
                </div>
                </div>

                <div class="col-xs-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label is-required">证书文件：</label>
                        <div class="col-sm-8">
                            <input type="hidden" name="rewardWenjian">
                            <div class="file-loading">
                                <input class="form-control file-upload" id="rewardWenjian" name="file" type="file">
                            </div>
                        </div>
                    </div>
                </div>

                <div class="col-xs-6">
                <div class="form-group">
                   <label class="col-sm-4 control-label is-required">等级：</label>
                    <div class="col-sm-8">
                        <select id="rewarDengji"  name="rewardDengji" class="form-control" type="text" th:with="type=${@dict.getType('sys_reward_dengji')}" required>
<!--                            <option>一等奖</option>-->
<!--                            <option>二等奖</option>-->
<!--                            <option>三等奖</option>-->
<!--                            <option>四等奖</option>-->
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                        </select>
                    </div>
                </div>
                </div>



            </div>
        </form>
    </div>
    <div class="row">
        <div class="col-sm-offset-5 col-sm-10">
            <button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i>保 存</button>&nbsp;
            <button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i class="fa fa-reply-all"></i>关 闭 </button>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <th:block th:include="include :: bootstrap-fileinput-js"/>
    <script type="text/javascript">
        var prefix = ctx + "system/reward"
        $("#form-reward-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($("input[name='rewardWenjian']").val() === "") {
                $.modal.alertError("请添加证书文件");
                return false;
            }
            if ($.validate.form()) {
                $.operate.saveTab(prefix + "/add", $('#form-reward-add').serialize());
            }
        }

        $("input[name='rewardTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $(".file-upload").fileinput({
            uploadUrl: ctx + 'common/upload/jl',
            maxFileCount: 1,
            autoReplace: true,
            allowedFileExtensions: ["pdf"],
            slugCallback: function(filename) {
                if ($("input[name='rewardName']").val()===""){
                    $(".file-uploadb").fileinput('clear');
                    $.modal.alertError("请先输入荣誉名称");
                    return false;
                }
                // 自定义文件名生成规则
                fileExtension = filename.split('.').pop();
                const year = new Date().getFullYear();
                const newName = year +"-"+ $("input[name='rewardName']").val() +"-"+ "证书文件"+ "." + fileExtension;
                return newName;
            },
        }).on('fileuploaded', function (event, data, previewId, index) {
            $("input[name='" + event.currentTarget.id + "']").val(data.response.url)
        }).on('fileremoved', function (event, id, index) {
            $("input[name='" + event.currentTarget.id + "']").val('')
        })
    </script>
</body>
</html>